<template>
<div id="header">
	<a id="logo"></a>
	<!-- weather start-->
	<weather></weather>
	<!-- weather end -->
</div>
<!-- search start-->
<search></search>
<!-- search end-->
<div class="main">
	<div class="main__bd">
		<!-- school start -->
		<school></school>
		<!-- school end -->
		<!-- custom start -->
		<custom></custom>
		<!-- custom end -->
		<!-- other start -->
		<other></other>
		<!-- other end -->
	</div>
	<div class="main__aside">
		<!-- home start -->
		<home></home>
		<!-- home end -->
		<!-- more start -->
		<more></more>
		<!-- more end -->

		<special></special>

		<!-- qrcode start -->
		<qrcode v-el="qrcode"></qrcode>
		<!-- qrcode end -->
		<backtop v-el="backtop"></backtop>
	</div>
</div>
<div class="footer">
	<p>Copyright © 2012-2016 西邮导航 All Rights Reserved</p>
	<p>CreatShare 冀ICP备13001401号</p>
</div>
</template>

<script>
var weather = require('../components/pc/weather.vue'),
	search = require('../components/pc/search.vue'),
	school = require('../components/pc/school.vue'), //校内直达
	custom = require('../components/pc/custom.vue'),
	other = require('../components/pc/other.vue'),
	home = require('../components/pc/home.vue'),
	more = require('../components/pc/more.vue'),
	qrcode = require('../components/pc/qrcode.vue'),
	special = require('../components/pc/special.vue'),
	backtop = require('../components/pc/backtop.vue');

module.exports = {
	components : {
		'weather' : weather,
		'search' : search,
		'school' : school,
		'custom' : custom,
		'other' : other,
		'home' : home,
		'more' : more,
		'qrcode' : qrcode,
		'backtop' : backtop,
		'special' : special
	},
	ready : function(){
		this.setFixed([this.$$.qrcode, this.$$.backtop]);
	},
	methods : {
		setFixed : function(data){
			var status = 0,
				CLASS_NAME = "f-fix",
				num = 10, //当第一个元素距离顶部为num时
				qrcodeTop = data[0].offsetTop - num;//获取第一个元素距离顶部的高度

			window.onscroll = function(){
				var bodyScrollTop = document.documentElement.scrollTop || document.body.scrollTop;

				if (bodyScrollTop >= qrcodeTop) {
					//如果status不为0，则无需重复执行
					if (status === 0) {
						data.forEach(function (x){
							x.classList.add(CLASS_NAME);
							status = 1;
						})
					}
				} else {
					data.forEach(function (x){
						x.classList.remove(CLASS_NAME);
						status = 0;
					})
				}				

			}
		}
	}
}
</script>